import Taro from '@tarojs/taro'
import { formatTime } from './common'
// var fundebug = require('../libs/fundebug.0.8.2.min.js');
/**
 *
 * @param {string} name 错误名字
 * @param {string} action 错误动作描述
 * @param {string} info 错误信息，通常是 fail 返回的
 */
export const logError = (name, action, info = 'empty') => {
  let device = "";
  try {
    let deviceInfo = Taro.getSystemInfoSync()
    device = JSON.stringify(deviceInfo)
  } catch (err) {
    console.error('not support getSystemInfoSync api', err.message)
  }
  let time = formatTime(new Date())
  console.error(time, name, action, info, device)
  // if (typeof action !== 'object') {
  // fundebug.notify(name, action, info)
  // }
  // fundebug.notifyError(info, { name, action, device, time })
  if (typeof info === 'object') {
    info = JSON.stringify(info)
  }
  Taro.showModal({
    title: '提示',
    content: action,
    showCancel: false,
    success: function (res) {}
  })
}